package cn.jly.servlet3.controller;

import org.springframework.web.context.request.async.DeferredResult;

import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

/**
 * @author lanyangji
 * @description deferredResult队列，用以模拟消息队列
 * @date 2020/11/16 上午 10:13
 */
public class DeferredResultQueue {
    private static final Queue<DeferredResult<Object>> QUEUE = new ConcurrentLinkedQueue<>();

    public static void add(DeferredResult<Object> deferredResult){
        QUEUE.add(deferredResult);
    }

    public static DeferredResult<Object> get() {
        return QUEUE.poll();
    }
}
